package com.cloud.wyf.Mapper;

import com.cloud.wyf.Entity.LeaderShipScore;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface LeaderShipScoreMapper {

    @Insert("<script>insert into leadershipscore(uid,role,votepart,year) values " +
            "<foreach collection = 'list' item='record' separator=',' >" +
            "(#{record.uid},#{record.role},#{record.votepart},#{record.year})" +
            "</foreach></script>")
    int addLeaderShipScoreMult(List<LeaderShipScore> list);

    @Select("select * from leadershipscore where uid=#{uid}")
    List<LeaderShipScore> selelctLeaderShipScoreByUid(String uid);

    @Select("select * from leadershipscore")
    List<LeaderShipScore> selelctAllLeaderShipScore();

    @Select("select * from leadershipscore where uid=#{uid} and votepart=#{part}")
    LeaderShipScore selectLeaderShipByUAndP(@Param("uid")String uid,@Param("part")String part);

    @Update("<script>update leadershipscore set item1=#{item1},item2=#{item2},item3=#{item3},item4=#{item4}," +
            "item5=#{item5},score=#{score},submittime=now()," +
            "status=1,flag=0,year=#{year}<if test=\"description != null and description != '' \">,description=#{description}</if> " +
            "where uid=#{uid} and votepart=#{votepart}</script>")
    int updateLeaderShipScore(LeaderShipScore leaderScore);

    @Update("update leadershipscore set submittime=now(),flag=1 where uid=#{uid} and votepart=#{votepart}")
    int updateLeaderShipScoreQuit(@Param("uid") String uid,@Param("votepart")String votepart);

    @Select("<script>select * from leadershipscore where uid in <foreach collection='leader' item='uid' open='(' separator=',' close=')'>#{uid}</foreach>" +
            "and votepart=#{part}</script>")
    List<LeaderShipScore> batchSelectLeaderShipByUAndP(@Param("leader") List<String> leader,@Param("part") String part);
}
